import json

import requests

from tqdm import tqdm
url = f"http://localhost:{9001}/model/extract/entities"

def wrap(context: str):
    json_data = {
        "context": context
    }

    response = requests.post(url, json=json_data)
    return response.json()

test_file = "short_1195_internet.json"
with open(test_file, "r", encoding="utf-8") as f:
    data = json.load(f)
ret = []
# length = len(data)
length = 1000
for i in tqdm(range(length)):
    original_context = data[i]
    response = wrap(original_context)
    response['original_context'] = original_context
    ret.append(response)
with open("post_short_1195_internet.json", "w", encoding="utf-8") as f:
    json.dump(ret, f, ensure_ascii=False, indent=4)
